<template>
  <list-con :add-go-back="false">
    <list-item @showChitGeometry="showChitGeometry" @showDisasterGeometry="showDisasterGeometry"
               @goChitInfo="goChitInfo" @goDetail="goDetail" v-for="(item,index) in dataList" :data-item="item"
               :key="index"></list-item>
  </list-con>
</template>

<script>
import {chitQueryMixins} from "@/views/chitLook/components/chitQuery/chitQueryMixins";
import {getOrderDisasterData, queryOrderBase, queryOrderDetailsById} from "@/api/chit/chitListPage";

export default {
  name: "chitList",
  mixins: [chitQueryMixins],
  props: {
    queryParam: {
      type: String
    },
    listData: {
      type: Array
    },
  },
  data() {
    return {
      pageQueryParam: {
        pageNum: 1,
        pageSize: 1000,
      },
      dataList: [],
      total: 0,
    }
  },
  watch: {
    listData(val) {
      this.dataList = val
    },
    queryParam(val) {
      if (val == null || val == '') {
        this.dataList = []
      } else {
        this.getList()
      }
    }
  },
  methods: {
    getList() {
      this.startLoading('正在加载....')
      let owner = this;
      let {queryParam: keyword, pageQueryParam} = this
      let queryParam = {keyword}
      let param = {...queryParam, ...pageQueryParam}
      queryOrderBase(param).then(res => {
        owner.total = res.total
        owner.dataList = res.rows;
      }).finally(() => {
        owner.endLoading()
      })
    },
    showDisasterGeometry(dataItem) {
      this.startLoading('正在加载....')
      let owner = this;
      let param = {id: dataItem.id}
      getOrderDisasterData(param).then(res => {
        owner.$emit('showDisasterGeometry', res.data)
      }).finally(() => {
        owner.endLoading()
      })
    },
    showChitGeometry(dataItem) {
      this.startLoading('正在加载....')
      let owner = this;
      let param = {id: dataItem.id}
      queryOrderDetailsById(param).then(res => {
        owner.$emit('showChitGeometry', res.data.geoDataList)
      }).finally(() => {
        owner.endLoading()
      })
    },
  }
}
</script>

<style scoped>

</style>
